const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

exports.main = async (event, context) => {
  const db = cloud.database()
  
  try {
    // 创建店铺位置索引
    await db.collection('shops').createIndex({
      key: {
        'location.latitude': 1,
        'location.longitude': 1
      }
    })
    
    return {
      success: true,
      message: '索引创建成功'
    }
  } catch (error) {
    console.error('创建索引失败：', error)
    return {
      success: false,
      message: '创建索引失败',
      error: error.message || error
    }
  }
} 